<?php

class adminBreakingNews extends Controller
{

    public function index()
    {
    	// Verify if admin is logge in, otherwise redirect out
    	Helper::verifyAdminLoggedIn();
    	Helper::verifySuperAdminLoggedIn();
    	
	    $breaking_news = $this->model->getAllBreakingNews();
		//print "Categories Are : <pre>" . print_r($categories,true) . "</pre>";exit;
     
        // load views
        require APP . 'views/admin_templates/header.php';
        require APP . 'views/adminBreakingNews/index.php';
        require APP . 'views/admin_templates/footer.php';
    }
 
	public function addBreakingNews()
    {
    	// Verify if admin is logge in, otherwise redirect out
    	Helper::verifyAdminLoggedIn();

        if (isset($_POST["submit_add_BreakingNews"])){
            $this->model->addBreakingNews($_POST["news_en"],$_POST["news_ar"],$_POST["news"]);
        
              }
        
        header('location: ' . URL . 'adminBreakingNews');
    }

    public function deleteBreakingNews($breaking_news_id)
    {
    	// Verify if admin is logge in, otherwise redirect out
    	Helper::verifyAdminLoggedIn();
    	
        if (isset($breaking_news_id)) {
            $this->model->deleteBreakingNews($breaking_news_id);
        }

        header('location: ' . URL . 'adminBreakingNews');
    }

    
    public function ajaxGetStats()
    {
       // $amount_of_categories = $this->model->getAmountOfCategories();

        // simply echo out something. A supersimple API would be possible by echoing JSON here
       // echo $amount_of_categories;
    } 
}
